package com.dareway.reflex;

import com.dareway.reflex.annotation.test;

import java.lang.annotation.Annotation;

public class TestAnnotation {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
       Class<Student> clazz = Student.class;
        for (Annotation annotation : clazz.getAnnotations()) {
            System.out.println(annotation.annotationType());   //获取类型
            System.out.println(annotation instanceof test);   //直接判断是否为Test
            test test = (test) annotation;
            System.out.println(test.value()[0]);   //获取我们在注解中写入的内容
        }

        for (Annotation annotation : clazz.getMethod("test").getAnnotations()) {
            System.out.println(annotation.annotationType());   //获取类型
            System.out.println(annotation instanceof test);   //直接判断是否为Test
            test test = (test) annotation;
            System.out.println(test.value()[0]);   //获取我们在注解中写入的内容
        }
    }
}
